#!/bin/sh

FILE_REPOSITORY=$1
SLADAP_FILE=slapd.conf
ECOM_LDIF=gicom.ldif


echo "pgmufrimag">pwd
echo "pgmufrimag">>pwd
echo update
apt-get update -qq
sleep 1
apt-get update -qq
sleep 4
echo install LDAP
apt-get install -y -q slapd  < pwd
apt-get install -y -q ldap-utils
echo stop slapdp
service slapd stop
cp /etc/default/slapd /etc/default/slapd.orig
sed -e 's/^SLAPD_CONF=$/SLAPD_CONF=\/etc\/ldap\/slapd.conf/' /etc/default/slapd.orig > /etc/default/slapd
mkdir /var/lib/ldap/dc=gicom,dc=org/
chown -R openldap:openldap /var/lib/ldap/dc=gicom,dc=org/
wget -nv $FILE_REPOSITORY/conf/$SLADAP_FILE
cp slapd.conf /etc/ldap/slapd.conf
service slapd start
wget -nv $FILE_REPOSITORY/conf/$ECOM_LDIF
ldapadd -x -D "cn=Manager,dc=gicom,dc=org" -w secret -f gicom.ldif

